package cn.com.fuhuitong.main.mine.adapter

import android.annotation.SuppressLint
import android.content.Context
import android.view.View
import cn.com.fuhuitong.R
import cn.com.fuhuitong.base.BaseDelegateAdapter
import cn.com.fuhuitong.main.ItemViewType
import cn.com.fuhuitong.main.mine.entity.AddressEntity
import com.alibaba.android.vlayout.LayoutHelper
import kotlinx.android.synthetic.main.item_address_list.view.*

class AddressListAdapter(
    private val mContext: Context, private val mHelper: LayoutHelper
) : BaseDelegateAdapter<AddressEntity>(
    mContext = mContext,
    mHelper = mHelper,
    mLayoutId = R.layout.item_address_list,
    mItemViewType = ItemViewType.ADDRESS_LIST
) {

    init {
        addChildClickViewIds(R.id.text_address_name_edit)
    }

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(itemView: View, position: Int, itemData: AddressEntity) {
        super.onBindViewHolder(itemView, position, itemData)
        itemView.text_address_name_phone.text =
            "${itemData.contact_name}  ${itemData.contact_mobile}"
        itemView.text_address_name_address.text =
            "${itemData.province}${itemData.city}${itemData.area}${itemData.address}"
        itemView.text_address_is_default.visibility =
            if (itemData.is_default == 1) View.VISIBLE else View.GONE
    }
}

class AddressBottomAdapter(
    private val mContext: Context, private val mHelper: LayoutHelper
) : BaseDelegateAdapter<String>(
    mContext = mContext,
    mHelper = mHelper,
    mLayoutId = R.layout.item_address_bottom,
    mItemViewType = ItemViewType.ADDRESS_BOTTOM
)